﻿using Lidgren.Network;

namespace Network.Messages.FileTranser
{
    public class ResponseCopyFileMessage : NovaMessage
    {
        public uint Number;
        public uint SendIndex;
        public int ChunkLen;
        public byte[] TempBuffer;
        public ResponseCopyFileMessage() :
            base((ushort) CustomMessageType.ResponseCopyFile)
        {
        }

        public override void WritePayload(NetOutgoingMessage message)
        {
            base.WritePayload(message);
            message.Write(Number);
            message.Write(SendIndex);
            message.Write(ChunkLen);
            message.Write(TempBuffer,0,ChunkLen);
        }

        public override void ReadPayload(NetIncomingMessage message)
        {
            base.ReadPayload(message);
            Number = message.ReadUInt32();
            SendIndex = message.ReadUInt32();
            ChunkLen = message.ReadInt32();
            TempBuffer = message.ReadBytes(ChunkLen);
        }
    }
}